package homework01;
import java.util.Arrays;
import java.util.Random;
public class ArrayExercise {
    public static void main(String[] args) {
        //getMonthDay();
        //createArrays();
        createArrays1();
    }
    public static void createArrays1(){
        int[]a=new int[6];
        for (int m = 0; m < a.length; m++) {
            Random r=new Random();
            a[m]=r.nextInt(10)+1;
        }
        System.out.println(Arrays.toString(a));

    }
    public static void createArrays(){
        int[]a=new int[10];//动态初始化数组
        for (int j = 0; j < 10; j++) {
            a[j]=j+1;
            System.out.println(a[j]);
        }
    }
    public static void getMonthDay(){
        //1.创建一个数组，用来保存12个月的天数
        int[]a={31,28,31,30,31,30,31,31,30,31,30,31};
        //2.输出每个月的天数到控制台
        //此处的循环变量代表的是数组的下标：0~a.length-1;
        for (int i = 0; i < a.length; i++) {
            System.out.println((i+1)+"月有:["+"\t"+a[i]+"天]");
        }
    }
}
